package com.wangshouyu.mp.system.token;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import com.wangshouyu.mp.base.response.BaseResponse;

import java.util.Objects;

/**
 * @author 王守钰
 * @date 2020年08月16日 02:22
 * @description: 认证AccessToken
 */

public class AuthAccessToken extends BaseResponse {

    /**
     * ACCESS_TOKEN
     */
    @SerializedName(value = "access_token")
    @JsonProperty(value = "access_token")
    @JSONField(name = "access_token")
    private String accessToken;

    /**
     * 过期时间
     */
    @SerializedName(value = "expires_in")
    @JsonProperty(value = "expires_in")
    @JSONField(name = "expires_in")
    private int expiresIn;

    /**
     * 刷新Token
     */
    @SerializedName(value = "refresh_token")
    @JsonProperty(value = "refresh_token")
    @JSONField(name = "refresh_token")
    private String refreshToken;

    /**
     * 用户编号
     */
    @SerializedName(value = "openid")
    @JsonProperty(value = "openid")
    @JSONField(name = "openid")
    private String openId;

    /**
     * 参数
     */
    @SerializedName(value = "scope")
    @JsonProperty(value = "scope")
    @JSONField(name = "scope")
    private String scope;

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public int getExpiresIn() {
        return expiresIn;
    }

    public void setExpiresIn(int expiresIn) {
        this.expiresIn = expiresIn;
    }

    public String getRefreshToken() {
        return refreshToken;
    }

    public void setRefreshToken(String refreshToken) {
        this.refreshToken = refreshToken;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public String getScope() {
        return scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        AuthAccessToken that = (AuthAccessToken) o;
        return expiresIn == that.expiresIn &&
                Objects.equals(accessToken, that.accessToken) &&
                Objects.equals(refreshToken, that.refreshToken) &&
                Objects.equals(openId, that.openId) &&
                Objects.equals(scope, that.scope);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), accessToken, expiresIn, refreshToken, openId, scope);
    }

    @Override
    public String toString() {
        return "AuthAccessToken{" +
                "accessToken='" + accessToken + '\'' +
                ", expiresIn=" + expiresIn +
                ", refreshToken='" + refreshToken + '\'' +
                ", openId='" + openId + '\'' +
                ", scope='" + scope + '\'' +
                '}';
    }
}
